package com.framework.plm.sec.encoder;

import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder;


/**
 * 消息摘要(MD5)加密算法加密器
 *
 */
public class MD5PasswordEncoder extends MessageDigestPasswordEncoder implements IPasswordEncoder {

	public MD5PasswordEncoder() {
		super("MD5");		
	}
	
	public String encode(String password) {
		return encodePassword(password, "");
	}

	public boolean isPasswordValid(String encPass, String rawPass, Object salt) {
        String pass1 = "" + encPass;
        String pass2 = null;
        if(rawPass.length() >= 32){
        	pass2 = rawPass;
        }else{
        	pass2 = encodePassword(rawPass, salt);
        }
        return pass1.equals(pass2);
    }
}